<script type="text/javascript" language="javascript" src="<?php echo base_url('assets/js/edit_product.js'); ?>"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url('assets/bootbox/bootbox.js'); ?>"></script>
<div class="container-crm">
    <form class="form-horizontal" role="form" method="post" action="<?php echo base_url('products/update'); ?>">
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">Mã hàng hóa</label>
            <div class="col-sm-5">
                <input type="hidden" name="id" value="<?php echo $product->id ?>"/>
                <input type="text" name="product_code" value="<?php echo $product->product_code ?>" class="form-control" id="" placeholder="Mã hàng hóa">
            </div>
        </div>
        <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Tên hàng hóa</label>
            <div class="col-sm-5">
                <input name="product_name" type="text" value="<?php echo $product->product_name ?>" class="form-control" id="product_name" placeholder="Tên hàng hóa">
            </div>
        </div>
        <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Nhóm hàng</label>
            <div class="col-sm-5">
                <select class="form-control" name="category">
                    <?php if ($all_cats) { ?>
                        <option value="">Chọn danh mục sản phẩm</option>
                        <?php foreach ($all_cats as $cat) { ?>
                            <option <?php echo ($cat->id == $product->category ? 'selected="selected" ' : '') ?> value="<?php echo $cat->id; ?>"><?php echo $cat->name; ?></option>
                        <?php } ?>
                    <?php } else { ?>
                        <option value="">Không có danh mục sản phẩm</option>
                    <?php } ?>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Giá bán</label>
            <div class="col-sm-5">
                <input name="sale_price" type="text" value="<?php echo $product->sale_price ?>" class="form-control" id="sale_price" placeholder="Giá bán">
            </div>
        </div>
        <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Giá vốn</label>
            <div class="col-sm-5">
                <input name="cost_price" type="text" value="<?php echo $product->cost_price ?>" class="form-control" id="cost_price" placeholder="Giá vốn">
            </div>
        </div>

        <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Tồn kho</label>
            <div class="col-sm-5">
                <input type="in_stock" class="form-control" id="cost_price" placeholder="Tồn kho">
            </div>
        </div>
        <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label"></label>
            <div class="col-sm-5">
                <button id="remove_selected_image" aria-expanded="false" data-toggle="dropdown" class="btn btn-danger dropdown-toggle" type="button">Xóa hình được chọn</button>
            </div>
        </div>
        <?php if (count($images->data) > 0) { ?>
            <div class="form-group">
                <label for="inputPassword3" class="col-sm-2 control-label"></label>
                <div class="col-sm-5">

                    <table id="list_images_product" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                        <thead>
                            <tr>
                                <th>Hình ảnh</th>

                            </tr>
                        </thead>
                        <tbody>
                            
                            <?php foreach ($images->data as $image) { ?>
                                <tr data-image-id="<?php echo $image->id ?>" data-product-id="<?php echo $product->id ?>">
                                    <td width="100" height="100"><img width="100" height="100" src="<?php echo base_url() ?>files/<?php echo $image->file_name ?>"/></td>
                                </tr>

                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
            <?php
        }
        ?>

        <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Thêm ảnh</label>
            <div class="col-sm-5">


                <input type="file" name="file_name[]" id="file_name" multiple>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-default">Lưu</button>
            </div>
        </div>
    </form>
</div>
